const { getMovieInfoFromOnlineById, getMovieCelebritiesFromOnlineById, getCelebrityInfoFromOnlineById, getCelebrityPhotoFromOnlineById } = require('../douban/movie');
const { getSearchResultFromOnlineMovie } = require('../douban/search');

/**
 * 电影演员搜索
 * @param {搜索关键字} text 
 * @param {分页开始} start 
 * @returns 
 */
async function searchMovieByText(text, start) {
  const result = await getSearchResultFromOnlineMovie(text, start);
  if (result) {
    result.forEach(element => {
      element['search_text'] = text;
    });
  }
  return result;
}

/**
 * 电影详情
 * @param {电影id} subjectId 
 * @returns 
 */
async function getMovieInfoById(subjectId) {
  return await getMovieInfoFromOnlineById(subjectId);
}

/**
 * 获取电影全部演员
 * @param {电影id} subjectId 
 * @returns 
 */
async function getMovieCelebritiesById(subjectId) {
  return await getMovieCelebritiesFromOnlineById(subjectId);
}

/**
 * 获取演员详情
 * @param {演员id} artistId 
 * @returns 
 */
async function getCelebrityInfoById(artistId) {
  return await getCelebrityInfoFromOnlineById(artistId);
}

/**
 * 获取电影演员全部图库
 * @param {电影id} artistId 
 * @returns 
 */
async function getCelebrityPhotoById(artistId) {
  return await getCelebrityPhotoFromOnlineById(artistId);
}

module.exports = {
  searchMovieByText,
  getMovieInfoById,
  getCelebrityInfoById,
  getCelebrityPhotoById,
  getMovieCelebritiesById
};